namespace SmartSoft.SystemForms
{
    using SmartSoft;
    using SmartSoft.Controls;
    using SmartSoft.ADP;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormUserRights : FormControl
    {
        private BtnControl btnCancel;
        private BtnControl btnOk;
        private BtnControl btnReset;
        private DataGridViewTextBoxColumn Column1;
        private DataGridViewCheckBoxColumn Column2;
        private DataGridViewCheckBoxColumn Column3;
        private DataGridViewCheckBoxColumn Column4;
        private DataGridViewCheckBoxColumn Column5;
        private IContainer components;
        private DataGridViewCheckBoxColumn dataGridViewCheckBoxColumn3;
        private DataGridViewCheckBoxColumn dataGridViewCheckBoxColumn6;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn5;
        private GridControl grdInvoice;
        private GridControl grdList;
        private GridControl grdMenu;
        private GridControl grdReport;
        private GridControl grdSubsidiary;
        private object ii_UserOrder = 0;
        private string is_UserOrGroup = "U";
        private UserDataAccess oMethod = new UserDataAccess();        
        private DataTable oTableA;
        private DataTable oTableL;
        private DataTable oTableM;
        private DataTable oTableR;
        private DataTable oTableU;
        private DataTable oTableV;
        private TabPage Page1;
        private TabPage Page2;
        private TabPage Page3;
        private TabPage Page4;
        private TabPage Page6;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
        private DataGridViewCheckBoxColumn dataGridViewCheckBoxColumn2;
        private DataGridViewCheckBoxColumn Column6;
        private DataGridViewCheckBoxColumn Column7;
        private DataGridViewCheckBoxColumn Column8;
        private DataGridViewCheckBoxColumn Column9;
        private DataGridViewCheckBoxColumn Column10;
        private CheckBox chkCheckAll;
        private CheckBox chkReportCheckAll;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
        private DataGridViewCheckBoxColumn dataGridViewCheckBoxColumn1;
        private TabContol tabControl;

        public FormUserRights(string ps_UserOrGroup, object pi_UserOrder)
        {
            this.InitializeComponent();
            this.grdMenu.AutoGenerateColumns = false;
            this.grdList.AutoGenerateColumns = false;
            this.grdInvoice.AutoGenerateColumns = false;
            this.grdReport.AutoGenerateColumns = false;
            this.grdSubsidiary.AutoGenerateColumns = false;
            this.UserOrGroup = ps_UserOrGroup;
            this.UserOrder = pi_UserOrder;
            this.FillData();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            base.Close();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            this.Save();
            base.Close();
        }

        private void btnReset_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Chắc chắn muốn đặt lại quyền?", AppInstance.SoftwareName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.No)
            {
                this.oMethod.ResetRights(this.UserOrGroup, this.UserOrder);
                this.FillData();
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void FillData()
        {            
            this.oTableM = this.oMethod.GetUserRights("M", this.UserOrder, this.UserOrGroup);
            this.grdMenu.DataSource = new BindingSource(this.oTableM, string.Empty);
            this.oTableL = this.oMethod.GetUserRights("L", this.UserOrder, this.UserOrGroup);
            this.grdList.DataSource = new BindingSource(this.oTableL, string.Empty);
            this.oTableV = this.oMethod.GetUserRights("V", this.UserOrder, this.UserOrGroup);
            this.grdInvoice.DataSource = new BindingSource(this.oTableV, string.Empty);
            this.oTableR = this.oMethod.GetUserRights("R", this.UserOrder, this.UserOrGroup);
            this.grdReport.DataSource = new BindingSource(this.oTableR, string.Empty);
            this.oTableA = this.oMethod.GetUserRights("A", this.UserOrder, this.UserOrGroup);
            this.oTableU = this.oMethod.GetUserRights("U", this.UserOrder, this.UserOrGroup);
            this.grdSubsidiary.DataSource = new BindingSource(this.oTableU, string.Empty);
        }

        private void InitializeComponent()
        {
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
            this.tabControl = new SmartSoft.Controls.TabContol();
            this.Page1 = new System.Windows.Forms.TabPage();
            this.grdMenu = new SmartSoft.Controls.GridControl();
            this.Page2 = new System.Windows.Forms.TabPage();
            this.grdList = new SmartSoft.Controls.GridControl();
            this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column2 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
            this.Column3 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
            this.Column4 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
            this.Column5 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
            this.Page3 = new System.Windows.Forms.TabPage();
            this.grdInvoice = new SmartSoft.Controls.GridControl();
            this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridViewCheckBoxColumn2 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
            this.Column6 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
            this.Column7 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
            this.Column8 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
            this.Column9 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
            this.Column10 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
            this.Page4 = new System.Windows.Forms.TabPage();
            this.chkReportCheckAll = new System.Windows.Forms.CheckBox();
            this.grdReport = new SmartSoft.Controls.GridControl();
            this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridViewCheckBoxColumn3 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
            this.Page6 = new System.Windows.Forms.TabPage();
            this.chkCheckAll = new System.Windows.Forms.CheckBox();
            this.grdSubsidiary = new SmartSoft.Controls.GridControl();
            this.dataGridViewTextBoxColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridViewCheckBoxColumn6 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
            this.btnCancel = new SmartSoft.Controls.BtnControl();
            this.btnOk = new SmartSoft.Controls.BtnControl();
            this.btnReset = new SmartSoft.Controls.BtnControl();
            this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridViewCheckBoxColumn1 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
            this.tabControl.SuspendLayout();
            this.Page1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.grdMenu)).BeginInit();
            this.Page2.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.grdList)).BeginInit();
            this.Page3.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.grdInvoice)).BeginInit();
            this.Page4.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.grdReport)).BeginInit();
            this.Page6.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.grdSubsidiary)).BeginInit();
            this.SuspendLayout();
            // 
            // tabControl
            // 
            this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.tabControl.Controls.Add(this.Page1);
            this.tabControl.Controls.Add(this.Page2);
            this.tabControl.Controls.Add(this.Page3);
            this.tabControl.Controls.Add(this.Page4);
            this.tabControl.Controls.Add(this.Page6);
            this.tabControl.Font = new System.Drawing.Font("Arial", 8.25F);
            this.tabControl.Location = new System.Drawing.Point(12, 12);
            this.tabControl.Name = "tabControl";
            this.tabControl.SelectedIndex = 0;
            this.tabControl.Size = new System.Drawing.Size(770, 479);
            this.tabControl.TabIndex = 0;
            // 
            // Page1
            // 
            this.Page1.Controls.Add(this.grdMenu);
            this.Page1.Location = new System.Drawing.Point(4, 23);
            this.Page1.Name = "Page1";
            this.Page1.Padding = new System.Windows.Forms.Padding(3);
            this.Page1.Size = new System.Drawing.Size(762, 452);
            this.Page1.TabIndex = 0;
            this.Page1.Text = "Truy cập menu";
            this.Page1.UseVisualStyleBackColor = true;
            // 
            // grdMenu
            // 
            this.grdMenu.AllowUserToAddRows = false;
            this.grdMenu.AllowUserToDeleteRows = false;
            this.grdMenu.AllowUserToOrderColumns = true;
            this.grdMenu.AllowUserToResizeRows = false;
            this.grdMenu.CheckColor = false;
            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
            dataGridViewCellStyle1.Font = new System.Drawing.Font("Arial", 8.25F);
            dataGridViewCellStyle1.ForeColor = System.Drawing.Color.Red;
            dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
            dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
            dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
            this.grdMenu.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
            this.grdMenu.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.grdMenu.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.dataGridViewTextBoxColumn1,
            this.dataGridViewCheckBoxColumn1});
            this.grdMenu.Dock = System.Windows.Forms.DockStyle.Fill;
            this.grdMenu.Enabled = false;
            this.grdMenu.Font = new System.Drawing.Font("Arial", 8.25F);
            this.grdMenu.Location = new System.Drawing.Point(3, 3);
            this.grdMenu.Name = "grdMenu";
            this.grdMenu.Size = new System.Drawing.Size(756, 446);
            this.grdMenu.TabIndex = 2;
            // 
            // Page2
            // 
            this.Page2.Controls.Add(this.grdList);
            this.Page2.Location = new System.Drawing.Point(4, 23);
            this.Page2.Name = "Page2";
            this.Page2.Padding = new System.Windows.Forms.Padding(3);
            this.Page2.Size = new System.Drawing.Size(762, 452);
            this.Page2.TabIndex = 1;
            this.Page2.Text = "Cập nhật danh mục";
            this.Page2.UseVisualStyleBackColor = true;
            // 
            // grdList
            // 
            this.grdList.AllowUserToAddRows = false;
            this.grdList.AllowUserToDeleteRows = false;
            this.grdList.AllowUserToOrderColumns = true;
            this.grdList.AllowUserToResizeRows = false;
            this.grdList.CheckColor = false;
            this.grdList.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.grdList.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.Column1,
            this.Column2,
            this.Column3,
            this.Column4,
            this.Column5});
            this.grdList.Dock = System.Windows.Forms.DockStyle.Fill;
            this.grdList.Font = new System.Drawing.Font("Arial", 8.25F);
            this.grdList.Location = new System.Drawing.Point(3, 3);
            this.grdList.Name = "grdList";
            this.grdList.Size = new System.Drawing.Size(756, 446);
            this.grdList.TabIndex = 1;
            // 
            // Column1
            // 
            this.Column1.DataPropertyName = "Ten_File";
            this.Column1.FillWeight = 58.32116F;
            this.Column1.HeaderText = "Chức năng";
            this.Column1.Name = "Column1";
            this.Column1.ReadOnly = true;
            this.Column1.Width = 400;
            // 
            // Column2
            // 
            this.Column2.DataPropertyName = "Right_1";
            this.Column2.FillWeight = 98.24142F;
            this.Column2.HeaderText = "Thêm";
            this.Column2.Name = "Column2";
            this.Column2.Width = 50;
            // 
            // Column3
            // 
            this.Column3.DataPropertyName = "Right_2";
            this.Column3.FillWeight = 83.86249F;
            this.Column3.HeaderText = "Sửa";
            this.Column3.Name = "Column3";
            this.Column3.Width = 50;
            // 
            // Column4
            // 
            this.Column4.DataPropertyName = "Right_3";
            this.Column4.FillWeight = 75.28648F;
            this.Column4.HeaderText = "Xóa";
            this.Column4.Name = "Column4";
            this.Column4.Width = 50;
            // 
            // Column5
            // 
            this.Column5.DataPropertyName = "Right_4";
            this.Column5.FillWeight = 50F;
            this.Column5.HeaderText = "Gộp mã";
            this.Column5.Name = "Column5";
            this.Column5.Width = 50;
            // 
            // Page3
            // 
            this.Page3.Controls.Add(this.grdInvoice);
            this.Page3.Location = new System.Drawing.Point(4, 23);
            this.Page3.Name = "Page3";
            this.Page3.Padding = new System.Windows.Forms.Padding(3);
            this.Page3.Size = new System.Drawing.Size(762, 452);
            this.Page3.TabIndex = 2;
            this.Page3.Text = "Cập nhật chứng từ";
            this.Page3.UseVisualStyleBackColor = true;
            // 
            // grdInvoice
            // 
            this.grdInvoice.AllowUserToAddRows = false;
            this.grdInvoice.AllowUserToDeleteRows = false;
            this.grdInvoice.AllowUserToOrderColumns = true;
            this.grdInvoice.AllowUserToResizeRows = false;
            this.grdInvoice.CheckColor = false;
            this.grdInvoice.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.grdInvoice.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.dataGridViewTextBoxColumn2,
            this.dataGridViewCheckBoxColumn2,
            this.Column6,
            this.Column7,
            this.Column8,
            this.Column9,
            this.Column10});
            this.grdInvoice.Dock = System.Windows.Forms.DockStyle.Fill;
            this.grdInvoice.Font = new System.Drawing.Font("Arial", 8.25F);
            this.grdInvoice.Location = new System.Drawing.Point(3, 3);
            this.grdInvoice.Name = "grdInvoice";
            this.grdInvoice.Size = new System.Drawing.Size(756, 446);
            this.grdInvoice.TabIndex = 3;
            // 
            // dataGridViewTextBoxColumn2
            // 
            this.dataGridViewTextBoxColumn2.DataPropertyName = "Ten_Ct";
            this.dataGridViewTextBoxColumn2.FillWeight = 58.32116F;
            this.dataGridViewTextBoxColumn2.HeaderText = "Chức năng";
            this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
            this.dataGridViewTextBoxColumn2.ReadOnly = true;
            this.dataGridViewTextBoxColumn2.Width = 400;
            // 
            // dataGridViewCheckBoxColumn2
            // 
            this.dataGridViewCheckBoxColumn2.DataPropertyName = "Right_1";
            this.dataGridViewCheckBoxColumn2.FillWeight = 98.24142F;
            this.dataGridViewCheckBoxColumn2.HeaderText = "Thêm";
            this.dataGridViewCheckBoxColumn2.Name = "dataGridViewCheckBoxColumn2";
            this.dataGridViewCheckBoxColumn2.Width = 50;
            // 
            // Column6
            // 
            this.Column6.DataPropertyName = "Right_2";
            this.Column6.HeaderText = "Sửa";
            this.Column6.Name = "Column6";
            this.Column6.Width = 50;
            // 
            // Column7
            // 
            this.Column7.DataPropertyName = "Right_3";
            this.Column7.HeaderText = "Xóa";
            this.Column7.Name = "Column7";
            this.Column7.Width = 50;
            // 
            // Column8
            // 
            this.Column8.DataPropertyName = "Right_4";
            this.Column8.HeaderText = "Xem";
            this.Column8.Name = "Column8";
            this.Column8.Width = 50;
            // 
            // Column9
            // 
            this.Column9.DataPropertyName = "Right_5";
            this.Column9.HeaderText = "Duyệt";
            this.Column9.Name = "Column9";
            this.Column9.Width = 50;
            // 
            // Column10
            // 
            this.Column10.DataPropertyName = "Right_6";
            this.Column10.HeaderText = "Khóa";
            this.Column10.Name = "Column10";
            this.Column10.Width = 50;
            // 
            // Page4
            // 
            this.Page4.Controls.Add(this.chkReportCheckAll);
            this.Page4.Controls.Add(this.grdReport);
            this.Page4.Location = new System.Drawing.Point(4, 23);
            this.Page4.Name = "Page4";
            this.Page4.Padding = new System.Windows.Forms.Padding(3);
            this.Page4.Size = new System.Drawing.Size(762, 452);
            this.Page4.TabIndex = 3;
            this.Page4.Text = "Xem báo cáo";
            this.Page4.UseVisualStyleBackColor = true;
            // 
            // chkReportCheckAll
            // 
            this.chkReportCheckAll.AutoSize = true;
            this.chkReportCheckAll.Location = new System.Drawing.Point(478, 8);
            this.chkReportCheckAll.Name = "chkReportCheckAll";
            this.chkReportCheckAll.Size = new System.Drawing.Size(15, 14);
            this.chkReportCheckAll.TabIndex = 113;
            this.chkReportCheckAll.UseVisualStyleBackColor = true;
            this.chkReportCheckAll.CheckedChanged += new System.EventHandler(this.chkReportCheckAll_CheckedChanged);
            // 
            // grdReport
            // 
            this.grdReport.AllowUserToAddRows = false;
            this.grdReport.AllowUserToDeleteRows = false;
            this.grdReport.AllowUserToOrderColumns = true;
            this.grdReport.AllowUserToResizeRows = false;
            this.grdReport.CheckColor = false;
            this.grdReport.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.grdReport.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.dataGridViewTextBoxColumn3,
            this.dataGridViewCheckBoxColumn3});
            this.grdReport.Dock = System.Windows.Forms.DockStyle.Fill;
            this.grdReport.Font = new System.Drawing.Font("Arial", 8.25F);
            this.grdReport.Location = new System.Drawing.Point(3, 3);
            this.grdReport.Name = "grdReport";
            this.grdReport.Size = new System.Drawing.Size(756, 446);
            this.grdReport.TabIndex = 2;
            // 
            // dataGridViewTextBoxColumn3
            // 
            this.dataGridViewTextBoxColumn3.DataPropertyName = "Bar";
            this.dataGridViewTextBoxColumn3.FillWeight = 58.32116F;
            this.dataGridViewTextBoxColumn3.HeaderText = "Chức năng";
            this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
            this.dataGridViewTextBoxColumn3.ReadOnly = true;
            this.dataGridViewTextBoxColumn3.Width = 400;
            // 
            // dataGridViewCheckBoxColumn3
            // 
            this.dataGridViewCheckBoxColumn3.DataPropertyName = "Right_1";
            this.dataGridViewCheckBoxColumn3.FillWeight = 98.24142F;
            this.dataGridViewCheckBoxColumn3.HeaderText = "Cấm";
            this.dataGridViewCheckBoxColumn3.Name = "dataGridViewCheckBoxColumn3";
            this.dataGridViewCheckBoxColumn3.Width = 50;
            // 
            // Page6
            // 
            this.Page6.Controls.Add(this.chkCheckAll);
            this.Page6.Controls.Add(this.grdSubsidiary);
            this.Page6.Location = new System.Drawing.Point(4, 23);
            this.Page6.Name = "Page6";
            this.Page6.Padding = new System.Windows.Forms.Padding(3);
            this.Page6.Size = new System.Drawing.Size(762, 452);
            this.Page6.TabIndex = 5;
            this.Page6.Text = "Chọn đơn vị cơ sở";
            this.Page6.UseVisualStyleBackColor = true;
            // 
            // chkCheckAll
            // 
            this.chkCheckAll.AutoSize = true;
            this.chkCheckAll.Location = new System.Drawing.Point(478, 8);
            this.chkCheckAll.Name = "chkCheckAll";
            this.chkCheckAll.Size = new System.Drawing.Size(15, 14);
            this.chkCheckAll.TabIndex = 112;
            this.chkCheckAll.UseVisualStyleBackColor = true;
            this.chkCheckAll.CheckedChanged += new System.EventHandler(this.chkCheckAll_CheckedChanged);
            // 
            // grdSubsidiary
            // 
            this.grdSubsidiary.AllowUserToAddRows = false;
            this.grdSubsidiary.AllowUserToDeleteRows = false;
            this.grdSubsidiary.AllowUserToOrderColumns = true;
            this.grdSubsidiary.AllowUserToResizeRows = false;
            this.grdSubsidiary.CheckColor = false;
            this.grdSubsidiary.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.grdSubsidiary.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.dataGridViewTextBoxColumn5,
            this.dataGridViewCheckBoxColumn6});
            this.grdSubsidiary.Dock = System.Windows.Forms.DockStyle.Fill;
            this.grdSubsidiary.Font = new System.Drawing.Font("Arial", 8.25F);
            this.grdSubsidiary.Location = new System.Drawing.Point(3, 3);
            this.grdSubsidiary.Name = "grdSubsidiary";
            this.grdSubsidiary.Size = new System.Drawing.Size(756, 446);
            this.grdSubsidiary.TabIndex = 2;
            // 
            // dataGridViewTextBoxColumn5
            // 
            this.dataGridViewTextBoxColumn5.DataPropertyName = "Ten_Dvcs";
            this.dataGridViewTextBoxColumn5.FillWeight = 58.32116F;
            this.dataGridViewTextBoxColumn5.HeaderText = "Chức năng";
            this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5";
            this.dataGridViewTextBoxColumn5.ReadOnly = true;
            this.dataGridViewTextBoxColumn5.Width = 400;
            // 
            // dataGridViewCheckBoxColumn6
            // 
            this.dataGridViewCheckBoxColumn6.DataPropertyName = "Right_1";
            this.dataGridViewCheckBoxColumn6.FillWeight = 98.24142F;
            this.dataGridViewCheckBoxColumn6.HeaderText = "Cấm";
            this.dataGridViewCheckBoxColumn6.Name = "dataGridViewCheckBoxColumn6";
            this.dataGridViewCheckBoxColumn6.Width = 50;
            // 
            // btnCancel
            // 
            this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.btnCancel.Font = new System.Drawing.Font("Arial", 8.25F);
            this.btnCancel.Location = new System.Drawing.Point(700, 497);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new System.Drawing.Size(75, 23);
            this.btnCancel.TabIndex = 3;
            this.btnCancel.Text = "&Hủy bỏ";
            this.btnCancel.UseVisualStyleBackColor = true;
            this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
            // 
            // btnOk
            // 
            this.btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.btnOk.Font = new System.Drawing.Font("Arial", 8.25F);
            this.btnOk.Location = new System.Drawing.Point(619, 497);
            this.btnOk.Name = "btnOk";
            this.btnOk.Size = new System.Drawing.Size(75, 23);
            this.btnOk.TabIndex = 2;
            this.btnOk.Text = "&Chấp nhận";
            this.btnOk.UseVisualStyleBackColor = true;
            this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
            // 
            // btnReset
            // 
            this.btnReset.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.btnReset.Font = new System.Drawing.Font("Arial", 8.25F);
            this.btnReset.Location = new System.Drawing.Point(538, 497);
            this.btnReset.Name = "btnReset";
            this.btnReset.Size = new System.Drawing.Size(75, 23);
            this.btnReset.TabIndex = 1;
            this.btnReset.Text = "&Reset";
            this.btnReset.UseVisualStyleBackColor = true;
            this.btnReset.Click += new System.EventHandler(this.btnReset_Click);
            // 
            // dataGridViewTextBoxColumn1
            // 
            this.dataGridViewTextBoxColumn1.DataPropertyName = "Bar";
            dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.dataGridViewTextBoxColumn1.DefaultCellStyle = dataGridViewCellStyle2;
            this.dataGridViewTextBoxColumn1.FillWeight = 58.32116F;
            this.dataGridViewTextBoxColumn1.HeaderText = "CHỨC NĂNG PHÂN QUYỀN TRUY CẬP MENU ĐANG TẠM KHÓA";
            this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
            this.dataGridViewTextBoxColumn1.Width = 400;
            // 
            // dataGridViewCheckBoxColumn1
            // 
            this.dataGridViewCheckBoxColumn1.DataPropertyName = "Right_1";
            this.dataGridViewCheckBoxColumn1.FillWeight = 98.24142F;
            this.dataGridViewCheckBoxColumn1.HeaderText = "Cấm";
            this.dataGridViewCheckBoxColumn1.Name = "dataGridViewCheckBoxColumn1";
            this.dataGridViewCheckBoxColumn1.Width = 50;
            // 
            // FormUserRights
            // 
            this.CancelButton = this.btnCancel;
            this.ClientSize = new System.Drawing.Size(794, 532);
            this.Controls.Add(this.btnCancel);
            this.Controls.Add(this.btnReset);
            this.Controls.Add(this.btnOk);
            this.Controls.Add(this.tabControl);
            this.MinimumSize = new System.Drawing.Size(802, 566);
            this.Name = "FormUserRights";
            this.Text = "Phân quyền";
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            this.tabControl.ResumeLayout(false);
            this.Page1.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.grdMenu)).EndInit();
            this.Page2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.grdList)).EndInit();
            this.Page3.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.grdInvoice)).EndInit();
            this.Page4.ResumeLayout(false);
            this.Page4.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.grdReport)).EndInit();
            this.Page6.ResumeLayout(false);
            this.Page6.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.grdSubsidiary)).EndInit();
            this.ResumeLayout(false);

        }

        private void Save()
        {
            for (int i = 0; i < this.oTableM.Rows.Count; i++)
            {                
                DataRow row = this.oTableM.Rows[i];
                row.EndEdit();                                
                if (row.RowState == DataRowState.Modified)
                {
                    this.oMethod.SaveRights(this.UserOrGroup, this.UserOrder, "M", row);
                }
            }

            for (int j = 0; j < this.oTableL.Rows.Count; j++)
            {
                DataRow row2 = this.oTableL.Rows[j];
                row2.EndEdit();
                if (row2.RowState == DataRowState.Modified)
                {
                    this.oMethod.SaveRights(this.UserOrGroup, this.UserOrder, "L", row2);
                }
            }
            for (int k = 0; k < this.oTableV.Rows.Count; k++)
            {
                DataRow row3 = this.oTableV.Rows[k];
                row3.EndEdit();
                if (row3.RowState == DataRowState.Modified)
                {
                    this.oMethod.SaveRights(this.UserOrGroup, this.UserOrder, "V", row3);
                }
            }
            for (int m = 0; m < this.oTableR.Rows.Count; m++)
            {
                DataRow row4 = this.oTableR.Rows[m];
                row4.EndEdit();
                if (row4.RowState == DataRowState.Modified)
                {
                    this.oMethod.SaveRights(this.UserOrGroup, this.UserOrder, "R", row4);
                }
            }
            for (int n = 0; n < this.oTableA.Rows.Count; n++)
            {
                DataRow row5 = this.oTableA.Rows[n];
                row5.EndEdit();
                if (row5.RowState == DataRowState.Modified)
                {
                    this.oMethod.SaveRights(this.UserOrGroup, this.UserOrder, "A", row5);
                }
            }
            for (int num6 = 0; num6 < this.oTableU.Rows.Count; num6++)
            {
                DataRow row6 = this.oTableU.Rows[num6];
                row6.EndEdit();
                if (row6.RowState == DataRowState.Modified)
                {
                    this.oMethod.SaveRights(this.UserOrGroup, this.UserOrder, "U", row6);
                }
            }
        }

        private object UserOrder
        {
            get
            {
                return this.ii_UserOrder;
            }
            set
            {
                this.ii_UserOrder = value;
            }
        }

        private string UserOrGroup
        {
            get
            {
                return this.is_UserOrGroup;
            }
            set
            {
                this.is_UserOrGroup = value;
            }
        }        

        private void chkCheckAll_CheckedChanged(object sender, EventArgs e)
        {
            if (this.chkCheckAll.Checked)
            {
                for (int i = 0; i < this.grdSubsidiary.Rows.Count; i++)
                    this.grdSubsidiary.Rows[i].Cells[1].Value = 1;
            }
            else
            {
                for (int i = 0; i < this.grdSubsidiary.Rows.Count; i++)
                    this.grdSubsidiary.Rows[i].Cells[1].Value = 0;
            }
        }

        private void chkReportCheckAll_CheckedChanged(object sender, EventArgs e)
        {
            if (this.chkReportCheckAll.Checked)
            {
                for (int i = 0; i < this.grdReport.Rows.Count; i++)
                    this.grdReport.Rows[i].Cells[1].Value = 1;
            }
            else
            {
                for (int i = 0; i < this.grdReport.Rows.Count; i++)
                    this.grdReport.Rows[i].Cells[1].Value = 0;
            }
        }
    }
}

